package com.forest.download.helper

import android.annotation.SuppressLint
import android.content.Context


@SuppressLint("StaticFieldLeak")
object Default {
    /**
     * 默认的分片大小
     */
    const val DEFAULT_RANGE_SIZE = 5L * 1024 * 1024

    /**
     * 单个任务同时下载的分片数量
     */
    const val DEFAULT_RANGE_CURRENCY = 5

    /**
     * 同时下载的任务数量
     */
    const val MAX_TASK_NUMBER = 10

    /**
     * 默认的Header
     */
    val RANGE_CHECK_HEADER = mapOf("Range" to "bytes=0-")

    var userAgentString:String? = null

    @SuppressLint("StaticFieldLeak")
    var context:Context? =null
    fun getUserAgent():String? {
        if (!userAgentString.isNullOrEmpty()){
            return userAgentString
        }
        try {
            val sp = context!!.getSharedPreferences("ua", Context.MODE_PRIVATE)
            userAgentString = sp.getString("ua", null)
            return userAgentString
        } catch (e: Exception) {

        }
        return null
    }
}